package exception;

/**
 * Throw关键字
 */
public class ThrowDemo {
    public static void main(String[] args) {
        Person p = new Person();
        try {
            p.setAge(1000);
        }catch (IllegalAgeException e){
            System.out.println(e);
        }
        try {
            p.setAge(999);
        } catch (IllegalAgeException e) {
            System.out.println(e);
        }
//        p.setAge(1000);
        System.out.println("年龄为:"+p.getAge());
    }
}
